<template>
  <div>
    <!-- <el-button type="primary" text @click="add"> 增加 </el-button> -->
    <!-- Form增加 -->
    <el-dialog v-model="dialogFormVisible" title="">
      <el-form :model="form">
        <el-form-item label="提车门店" :label-width="formLabelWidth">
          <el-input v-model="form.tcmd" autocomplete="off" />
        </el-form-item>
        <el-form-item label="门店电话" :label-width="formLabelWidth">
          <el-input v-model="form.mdtel" autocomplete="off" />
        </el-form-item>
        <el-form-item label="经度" :label-width="formLabelWidth">
          <el-input v-model="form.jingdu" autocomplete="off" />
        </el-form-item>
        <el-form-item label="纬度" :label-width="formLabelWidth">
          <el-input v-model="form.weidu" autocomplete="off" />
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="dialogFormVisible = false">取消</el-button>
          <el-button type="primary" @click="postData"> 确定 </el-button>
        </span>
      </template>
    </el-dialog>

    <el-table :data="tableData" style="width: 100%">
      <el-table-column
        fixed
        prop="receiver"
        label="姓名"
        width="140"
        align="center"
      />
      <el-table-column
        fixed
        prop="tel"
        label="手机号"
        width="160"
        align="center"
      />
      <el-table-column
        fixed
        prop="cxmc"
        label="车型名称"
        width="160"
        align="center"
      />
      <el-table-column
        fixed
        prop="colorname"
        label="车型颜色"
        width="160"
        align="center"
      />
      <el-table-column
        fixed
        prop="address_xq"
        label="提车地点"
        width="340"
        align="center"
      />
      <el-table-column
        fixed
        prop="order_sn"
        label="订单号"
        width="240"
        align="center"
      />
      <el-table-column
        fixed
        prop="tcmd"
        label="提车门店"
        width="340"
        align="center"
      />
      <el-table-column
        fixed
        prop="mdtel"
        label="门店电话"
        width="200"
        align="center"
      />
      <el-table-column
        fixed
        prop="jingdu"
        label="经度"
        width="160"
        align="center"
      />
      <el-table-column
        fixed
        prop="weidu"
        label="纬度"
        width="160"
        align="center"
      />
      <el-table-column fixed="right" label="操作" align="center">
        <template #default="scope">
          <el-button
            link
            type="primary"
            @click="tj(scope.row.id, scope.row.name)"
            v-if="scope.row.types == 1 || scope.row.types == 2"
            >添加奖项</el-button
          >
          <el-button link type="primary" @click="eid(scope.row.id)"
            >修改</el-button
          >
          <!-- <el-button link type="danger" @click="del(scope.row.id)"
            >删除</el-button
          > -->
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import UploadFile from "element-plus";
import { ElMessageBox, ElMessage } from "element-plus";
export default {
  components: {
    [UploadFile.name]: UploadFile,
  },
  data() {
    return {
      HttpImg: "http://gyycadmincss.hansn.cn",
      tableData: [],
      jxlist: [],
      jxform: [],
      form: [],
      form1: [],
      dialogFormVisible: false,
      dialogFormVisible1: false,
      dialogjx: false,
      formLabelWidth: "120px",
      imageUrl: "",
      options: [
        {
          value: "1",
          label: "赛艇系列",
        },
        {
          value: "2",
          label: "其他系列",
        },
      ],
      value: "",
      id: "",
      hdid: "",
      hdname: "",
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    tj(id, name) {
      this.dialogjx = true;
      this.hdid = id;
      this.hdname = name;
      this.getjxlist();
    },
    add() {
      this.form.cxmc = "";
      this.form.cxggy = "";
      this.form.cxjg = "";
      this.form.cxxl = "";
      this.form.img = "";
      this.form.lbcximg = "";
      this.form.xqttimg = "";
      this.dialogFormVisible = true;
      this.id = "";
      this.form.xqctimg = "";
    },

    del(id) {
      ElMessageBox.confirm("是否确定删除?", "", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$http
            .post("/index.php/index/Admincp/hdcxdel", {
              id: id,
            })
            .then((res) => {
              if (res.code == 200) {
                this.getData();
                ElMessage({
                  message: "删除成功",
                  type: "success",
                });
              }
            });
        })
        .catch(() => {});
    },
    eid(id) {
      console.log(id)
      this.dialogFormVisible = true;
      this.id = id;
      this.$http
        .post("/index.php/index/Admindshes/orderxq", {
          id: id,
        })
        .then((res) => {
          if (res.code == 200) {
            this.form = res.data;
          }
        });
    },
    // updateData() {
    // 	let data1 = {
    // 		id: this.form1.id,
    // 		name: this.form1.name,
    // 		cjzt: this.form1.cjzt,
    // 		kjtime:this.getTimeFormat(this.form1.kjtime),
    // 		images: this.form1.images,
    // 		twlink: this.form1.twlink,
    // 	}
    // 	console.log(data1)
    // 	this.$http.post("/index.php/index/goodses/cjupdate", data1).then(res => {
    // 		if (res.code == 200) {
    // 			this.dialogFormVisible1 = false;
    // 			this.getData()
    // 		 }
    // 	 })
    // },
    getData() {
      this.tableData = [];
      this.$http.post("/index.php/index/Admindshes/index").then((res) => {
        console.log(res);
        this.tableData = res.data;
      });
    },
    postData() {
      // this.form.cjzt = this.value;
      let data = {
        tcmd: this.form.tcmd,
        mdtel: this.form.mdtel,
        jingdu: this.form.jingdu,
        weidu: this.form.weidu,
        id: this.id,
      };
      this.$http
        .post(
          this.id
            ? "/index.php/index/Admindshes/orderedit"
            : "/index.php/index/Admincp/hdcxadd",
          data
        )
        .then((res) => {
          if (res.code == 200) {
            this.dialogFormVisible = false;
            this.id = "";
            ElMessage({
              message: this.id ? "编辑成功" : "新增成功",
              type: "success",
            });
            this.getData();
          }
        });
    },
    getTimeFormat(zcTime) {
      let time = new Date(zcTime).getTime() / 1000; //除1000 是变成秒级的时间戳 不除就是毫秒级
      return time;
    },
    disabledDateFun(time) {
      return time.getTime() < Date.now() - 8.64e7;
    },
    formatEmployment(type) {
      // 根据源数据经过处理 把处理之后的数据返回
      // 定义一个映射结构
      const map = {
        1: "赛艇系列",
        2: "其他系列",
      };
      return map[type];
    },
    getLocalTime(nS) {
      return new Date(parseInt(nS) * 1000)
        .toLocaleString()
        .replace(/:\d{1,2}$/, " ");
    },
  },
};
</script>
<style scoped>
.el-icon-plus {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}

.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>
